Page({
    data: {
        order: null,
        getGoodsTotalPrice: function() {
            return this.data.order.total_price;
        }
    },
    onLoad: function(e) {
        var t = this;
        getApp().page.onLoad(this, e);
        if (e.scene) {
          var m = decodeURIComponent(e.scene);
          var hh = getApp().helper.scene_decode(m);
          if (hh.user_id != '' && hh.user_id != undefined && hh.user_id != null && hh.user_id != 0) {
            e.user_id = hh.user_id
          } else {
            e.user_id = 0;
          }
           if (hh.type != '' && hh.type != undefined && hh.type != null && hh.type != 0) { 
            //获取核销卡信息
            getApp().request({
              url: getApp().api.verify.verify_order,
              data: {
                //order_no: 4
                order_no: hh.order_no
              },
              success: function (e) {
                0 == e.code ? t.setData({
                  order_type: hh.type,
                  order: e.data.list
                }) : getApp().core.showModal({
                  title: "警告！",
                  showCancel: !1,
                  content: e.msg,
                  confirmText: "确认",
                  success: function (e) {
                    e.confirm && getApp().core.switchTab({
                      url: "/pages/index/index"
                    });
                  }
                });
              },
              complete: function () {
                getApp().core.hideLoading();
              }
            });
           } 

        }

      if (hh.type == '' || hh.type == undefined || hh.type == null || hh.type == 0){
        var t = this, o = "";
        if ("undefined" == typeof my) o = e.scene; else if (null !== getApp().query) {
            var r = getApp().query;
            getApp().query = null, o = r.order_no;
        }
        t.setData({
            store: getApp().core.getStorageSync(getApp().const.STORE),
            user_info: getApp().getUser()
        }), getApp().core.showLoading({
            title: "正在加载"
        }), getApp().request({
            url: getApp().api.order.clerk_detail,
            data: {
                order_no: o,
                user_id: e.user_id
            },
            success: function(e) {
                0 == e.code ? t.setData({
                    order: e.data
                }) : getApp().core.showModal({
                    title: "警告！",
                    showCancel: !1,
                    content: e.msg,
                    confirmText: "确认",
                    success: function(e) {
                        e.confirm && getApp().core.switchTab({
                            url: "/pages/index/index"
                        });
                    }
                });
            },
            complete: function() {
                getApp().core.hideLoading();
            }
        });
      }
      
    },
    clerk: function(e) {
        var t = this;
        getApp().core.showModal({
            title: "提示",
            content: "是否确认核销？",
            success: function(e) {
                e.confirm && (getApp().core.showLoading({
                    title: "正在加载"
                }), getApp().request({
                    url: getApp().api.order.clerk,
                    data: {
                        order_no: t.data.order.order_no
                    },
                    success: function(e) {
                        0 == e.code ? getApp().core.switchTab({
                            url: "/pages/user/user"
                        }) : getApp().core.showModal({
                            title: "警告！",
                            showCancel: !1,
                            content: e.msg,
                            confirmText: "确认",
                            success: function(e) {
                                e.confirm && getApp().core.switchTab({
                                    url: "/pages/index/index"
                                });
                            }
                        });
                    },
                    complete: function() {
                        getApp().core.hideLoading();
                    }
                }));
            }
        });
    },
    clerkUser: function (t) {
      var r = this;
      var order_list = {};
      for (var i = 0; i < r.data.order.order_list.length; i++) {
        if (r.data.order.order_list[i].hexiao == 1) {
          order_list[i] = r.data.order.order_list[i].order_id;
        }
      }

      wx.showModal({
        title: "提示",
        content: "是否确认核销？",
        success: function (t) {
          t.confirm ? (wx.showLoading({
            title: "正在加载"
          }), getApp().request({
            url: getApp().api.order.clerk,
            data: {
              order_id_arr: order_list
            },
            success: function (e) {
              0 == e.code ? wx.showModal({
                title: "提示",
                showCancel: !1,
                content: e.msg,
                confirmText: "确认",
                success: function (e) {
                  e.confirm && wx.redirectTo({
                    url: "/pages/commander/index"
                  });
                }
              }) : wx.showModal({
                title: "警告！",
                showCancel: !1,
                content: e.msg,
                confirmText: "确认",
                success: function (e) {
                  e.confirm && wx.switchTab({
                    url: "/pages/index/index"
                  });
                }
              });
            },
            complete: function () {
              wx.hideLoading();
            }
          })) : t.cancel;
        }
      });
    },
    getHexiao: function (t) {
      var e = this, a = t.currentTarget.dataset.hexiao, i = t.currentTarget.dataset.index;
      e.data.order.order_list[i].hexiao = a;
      e.setData({
        order: e.data.order
      })
    },
  //核销卡
  clerkVerify: function (e) {
    var t = this;
    getApp().core.showModal({
      title: "提示",
      content: "是否确认核销？",
      success: function (e) {
        e.confirm && (getApp().core.showLoading({
          title: "正在加载"
        }), getApp().request({
          url: getApp().api.order.clerk_verify,
          data: {
            order_no: t.data.order.id,
            order_type:'verify'
          },
          success: function (e) {
            0 == e.code ? getApp().core.switchTab({
              url: "/pages/user/user"
            }) : getApp().core.showModal({
              title: "警告！",
              showCancel: !1,
              content: e.msg,
              confirmText: "确认",
              success: function (e) {
                e.confirm && getApp().core.switchTab({
                  url: "/pages/index/index"
                });
              }
            });
          },
          complete: function () {
            getApp().core.hideLoading();
          }
        }));
      }
    });
  },
});